#include <stdio.h>
#include<math.h>
int m(int n)
{int t,z,x,c;
int count=0;
int f;
for(t=11;t*t<=n;t++)
{f=t*t;
z=f%10;
f=f/10;
x=f%10;
f=f/10;
c=f%10;
if(z==x||z==c||c==x)
    {count++;}

}
return count;

}
int main()
{int n;
int p;
scanf("%d",&n);
p=m(n);
printf("%d",p);

    return 0;
}
